<?php
/**
 * jishupu-cms
 * @Author:技术铺
 * @Date:2022/2/27
 */

if (!function_exists('arrayReplaceRecursive')) {
    /**
     * 索引数组递归替换
     * @param array $array
     * @param array $repalce // 例：['password'=>'******']
     * @return array
     */
    function arrayReplaceRecursive($array = [], $repalce = [])
    {
        if (empty($array) || empty($repalce)) return [];
        foreach ($array as $key => $value) {
            foreach ($repalce as $rKey => $rValue) {
                if (is_array($value)) {
                    $array[$key] = arrayReplaceRecursive($value, $repalce);
                } else {
                    if ($key == $rKey) $array[$key] = $rValue;
                }
            }
        }
        return $array;
    }
}
